//
//  statusForwarCell.swift
//  波波微博
//
//  Created by wave on 15/8/3.
//  Copyright © 2015年 wave. All rights reserved.
//

import UIKit

class StatusForwarCell: StatusCell {
    
    //重写父类的status方法,重写属性方法并不会覆盖父类的方法,子类只需要设置自己的内容即可
    override var status:Status?{
        didSet{
        
            let name = status?.retweeted_status?.user?.name ?? ""
            let text = status?.retweeted_status?.text ?? ""
        
            forwardLabel.text = "@" + name + ":" + text
        }
    }
    
    
    //重写setupUI方法
    override func setupUI() {
        super.setupUI()
        
        contentView.insertSubview(backButton, belowSubview: pictureView)
        contentView.insertSubview(forwardLabel, aboveSubview: backButton)
        
        
        //设置布局
        //背景按钮
        backButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLabel, size: nil, offset: CGPoint(x: -statusCellControlMargin, y: statusCellControlMargin))
        backButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottomView, size: nil)
        //转发文本
        forwardLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backButton, size: nil, offset: CGPoint(x: statusCellControlMargin, y: statusCellControlMargin))
        
        //配图视图
        let cons = pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwardLabel, size: CGSize(width: 290, height: 290), offset: CGPoint(x: 0, y: statusCellControlMargin))
        pictureWidthCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Width)
        pictureHeightCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Height)
        pictureTopCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Top)
    }
    
    //懒加载控件
    //转发文字
    private lazy var forwardLabel : UILabel = {
        
        let l = UILabel(color:UIColor.darkGrayColor(), fontSize: 14)
        
        l.numberOfLines = 0
        
        l.preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * statusCellControlMargin
        
        return l
    }()
    //背景是一个按钮
    private lazy var backButton : UIButton = {
        
        let btn = UIButton()
        
        btn.backgroundColor = UIColor(white: 0.8, alpha: 1.0)
        
        return btn
    }()
    
    
}